//获取应用实例
var app = getApp()
var util = require('../../../utils/util.js')
Page({
  /**
   * 页面的初始数据
   */
  data: {
    grade:[
      // {text:"白银版",bg:"#848184",type:1},
    // {text:"黄金版",bg:"#E09E00",type:2},
    // {text:"钻石版",bg:"#624F0C",type:3},
    // {text:"白金版",bg:"#A8A8A8",type:4},
    // {text:"黑金版",bg:"#1A0C00",type:5},
    // {text:"钻石plus",bg:"#44090D",type:6},
    // {text:"旗舰版",bg:"#001D20",type:7},
        //
      {text:"普通店主",bg:"#848184",type:5},
      {text:"高级店主",bg:"#44090D",type:7},
  ],
    promotionObj:{
      1:{name:"初级推广员",num:5},
      2:{name:"中级推广员",num:10},
      3:{name:"高级推广员",num:20},
      4:{name:"金牌推广员",num:20}
    },
    next:{
      1:{name:"中级推广员",num:5},
      2:{name:"高级推广员",num:10},
      3:{name:"金牌推广员",num:20},
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // 登录
    let login  = wx.getStorageSync('isPhone');
    let customer_id = wx.getStorageSync('customer_id');
    if(!login  && ( !customer_id || (customer_id && (customer_id.head_url==""|| customer_id.phone=="" || !customer_id.phone || !customer_id.head_url)))){
      wx.navigateTo({
        url: '/pages/login/login?phone=true',
      })
    }

    this.getRecommend();
  },
  // 获取推广中心数据
  //
  getRecommend(){
    var that = this;
    wx.request({
      url: app.globalData.urls + '/order-manage/recommend-center',
      header: app.getRequestHeader(),
      method:"POST",
      data: {
        bdmin_user_id:util.getBdmin_user_id()
      },
      success: function (res) {
        if(res.data.code==200){
          that.setData(res.data.data)
          console.log("----res.data.data",res.data.data)
        }
      }
    })
  },
  // 我要推广
  myPromote(e){
    wx.navigateTo({
      url: '/pages/business/promote-code/promote-code?pType='+e.currentTarget.dataset.item.type,
    })
  },
/**
   * 用户点击右上角分享
   */
  onShareAppMessage:async function(ops) {

    let that = this,params = ops.target.dataset.item;
    return {
      // title: '天天精选',
      title: "["+that.data.store_name+"]邀请你开店，自用省钱，开店赚钱",
      path: '/pages/business/promote-state/promote-state?id='+util.getBdmin_user_id()+"&v="+params.type,
      imageUrl: "https://ttjx-1302259601.cos.ap-beijing.myqcloud.com/media/upload/m/u9/mu9mg9qjl58lvjd1598871770.png" ,  //用户分享出去的自定义图片大小为5:4,
      success: function (res) {
        // 转发成功
        wx.showToast({
          title: "邀请成功",
          icon: 'success',
          duration: 2000
        })
      },
      fail: function (res) {
        // 分享失败
        wx.showToast({
          title: "邀请失败",
          icon: 'error',
        })
      },
    }

  },
})
